package com.quanyan.user.serviceFacade.impl;

import com.quanyan.api.APIResponse;
import com.quanyan.user.mapper.DiscoveryVideoMapper;
import com.quanyan.user.response.RespPlaceVideoInfo;
import com.quanyan.user.response.RespVideoBaseInfo;
import com.quanyan.user.response.RespVideoDetail;
import com.quanyan.user.service.DiscoveryVideoService;
import com.quanyan.user.service.impl.DiscoveryVideoServiceImpl;
import com.quanyan.user.serviceFacade.VideoServiceFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by huadongyang on 2017/3/14.
 */
@Service("videoServiceFacade")
public class VideoServiceFacadeImpl implements VideoServiceFacade {
    private static final Logger logger = LoggerFactory.getLogger(VideoServiceFacadeImpl.class);

    @Autowired
    private DiscoveryVideoMapper discoveryVideoMapper;
    @Autowired
    private DiscoveryVideoService discoveryVideoService;

    @Override
    public APIResponse<List<RespPlaceVideoInfo>> getPlaceVideoInfo(List<Integer> placeIds) {
        if (placeIds == null || placeIds.size()<= 0) {
            return APIResponse.returnFail("请传入正确的参数");
        }
        try {
            return  APIResponse.returnSuccess(discoveryVideoMapper.getPlaceVideoInfos(placeIds));
        }catch (Exception e) {
            logger.error("获取场馆视频列表失败！{}", e);
            return APIResponse.returnFail("获取场馆视频失败");
        }
    }

    @Override
    public APIResponse<List<RespPlaceVideoInfo>> getPlaceVideosByPlaceId(Integer placeId, Integer pageSize) {
        if (placeId == null ) {
            return APIResponse.returnFail("请传入正确的参数");
        }
        if (pageSize <= 0) {
            return null;
        }

        try {
            return  APIResponse.returnSuccess(discoveryVideoMapper.getPlaceVideosByPlaceId(placeId, pageSize));
        }catch (Exception e) {
            logger.error("获取场馆视频列表失败！{}", e);
            return APIResponse.returnFail("获取场馆视频失败");
        }
    }

    /**
     * 获取达人视频推荐
     * @param uidList
     * @return
     */
    @Override
    public Map<Integer, RespVideoBaseInfo> getTalentRecommendVideo(List<Integer> uidList) {

        return discoveryVideoService.getTalentRecommendVideo(uidList);
    }
}
